/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef __PERFORMANCE_BUILER_HDR__
#define __PERFORMANCE_BUILER_HDR__

#pragma warning( disable : 4786 )

#include "data.h"
#include <memory>

namespace performance {

	//
	//
	//

	class Atmosphere;


    //
    // performance::Builder
    //

    class Builder {

    public:
        Builder();
        ~Builder();

    public:
		void build_data( int );

		void build_type( 
			const std::string &, const std::string &, int, int, int
		);

		void build_holding( double, double, double );
		void build_takeoff( double, double, double, double );
		void build_landing( double );
		void build_xsection( double );
		void build_maximums( double, double, double, bool, bool );
		void build_turn_speed( double );
		void build_turn_rates( double, double, double );
		void build_acceleration( double, double, double );
		void build_decelerations( double, double, double );
		void build_climb_rates( double, double, double );
		void build_descend_rates( double, double, double );

		void build_level_count( int );

		void build_altitude_levels( const std::vector< double > & );
		void build_climb_rate_levels( const std::vector< double > & );
		void build_descend_rate_levels( const std::vector< double > & );
		void build_acceleration_levels( const std::vector< double > & );
		void build_deceleration_levels( const std::vector< double > & );

		void build_cruising_speed_levels( const std::vector< std::string > & );
		void build_stall_speed_levels( const std::vector< std::string > & );
		void build_ascent_speed_levels( const std::vector< std::string > & );
		void build_descent_speed_levels( const std::vector< std::string > & );

		void build_sidstar( const std::string & );

		void accept_performance();

    public:
		std::auto_ptr< Data > data() { return _data; }

	private:
		LHM_CAT get_cat( const std::string & );
		std::vector< double > construct_level_velocities( 
				const std::vector< std::string > & 
		); 
		void generate_atmospheric_params();
		void generate_atmospheric_params( const std::vector< double > & );
		void build_maximum_speed_levels();
		double convert2tas( int, const char, double );

    private:
		std::auto_ptr< Data >     _data;
		PDO                      *_pdo;		// current PDO
		Atmosphere               *_atmos;
    
	};


};
#endif
